package com.hontech.kaltaapp.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.kaltaapp.R
import com.hontech.kaltaapp.device.doorCtrl
import com.hontech.kaltaapp.ui.dialog.runProg
import com.hontech.kaltaapp.utils.onClick

class DoorParts (context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_door, this)

        val btn = view.findViewById<Button>(R.id.id_door_btn_open)
        btn.onClick {
            runProg("门", "打开") {
                doorCtrl(0)
            }
        }

        val btnClose = view.findViewById<Button>(R.id.id_door_btn_close)
        btnClose.onClick {
            runProg("门", "关闭") {
                doorCtrl(1)
            }
        }
    }
}